package pl.iachoo.ctl.tabory.dao.ibatis;

import org.apache.log4j.Logger;
import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;

import pl.iachoo.ctl.tabory.dao.api.services.ICompositionService;
import pl.iachoo.ctl.tabory.dao.data.vo.CompositionVO;
import pl.iachoo.ctl.tabory.dao.ibatis.services.ServiceManager;

public class Activator implements BundleActivator {

	private final Logger logger = Logger.getLogger(Activator.class);

	public void start(BundleContext context) throws Exception {
		logger.info("Starting bundle: " + context.getBundle().getSymbolicName());
		ICompositionService compositionService = ServiceManager
				.getCompositionService();
		CompositionVO compositionVO = new CompositionVO();
		compositionVO.setActive(true);
		compositionVO.setInternalId(String.valueOf(System.currentTimeMillis())
				.substring(0, 9));
		compositionService.saveUpdateComposition(compositionVO);
		compositionService.getListAllCompositions();
	}

	public void stop(BundleContext context) throws Exception {
		logger.info("Stopping bundle: " + context.getBundle().getSymbolicName());
	}

}
